﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Reflection;

// “基本页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234237 上有介绍

namespace Sample
{
    /// <summary>
    /// 基本页，提供大多数应用程序通用的特性。
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }


        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            List<Type> types = new List<Type>();
            foreach (var item in this.GetType().GetTypeInfo().Assembly.DefinedTypes)
            {
                if (item.IsSubclassOf(typeof(Common.LayoutAwarePage)))
                {
                    types.Add(item.AsType());
                }
            }
            gridview.ItemsSource = types;
        }

        private void gridview_ItemClick_1(object sender, ItemClickEventArgs e)
        {
            Type t = e.ClickedItem as Type;
            this.Frame.Navigate(t);
        }
    }
}
